home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / wedits22.zip / WEMISC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-18  |  4KB  |  202 lines

  1. UNIT WEMisc; {$O+}
  2. { -- This is the Misc. Module of WWIVEdit 2.2.
  3.   -- Last Updated : 8/17/91
  4.   -- Written By: Adam Caldwell
  5.   --
  6.   -- This code is limited Public Domain (see WWIVEDIT.PAS for details
  7.   --
  8.   -- Known Errors : None
  9.   --
  10.   -- Planned Changes : Elimination of this unit.... Put the rest of the
  11.   --  stuff where it belongs
  12.   --
  13.   -- }
  14. {$R-,V-,S-,B-,E-,N-,F+}{ These Optomize things as much as possible }
  15.  
  16. INTERFACE
  17.  
  18. USES WEVars, WEString, WELine, WETime, WEKbd, WEOutput, WEInput;
  19.  
  20.  
  21. PROCEDURE input(VAR i:string;      { Allows user to input a string of         }
  22.                maxlength:integer); { MaxLength Characters                     }
  23. PROCEDURE InputUp(VAR i:string;    { Allows user to input a string of         }
  24.                maxlength:integer); { MaxLength then converts it to uppercase  }
  25. FUNCTION CheckAbort:boolean;       { Returns True if SPACE is pressed, will   }
  26.                                    { pause if P or Ctrl-S is pressed          }
  27.  
  28. PROCEDURE EnableInts; INLINE($FB);
  29. PROCEDURE DisableInts; INLINE($FA);
  30. PROCEDURE SaveInfo;
  31. PROCEDURE DoJump;
  32. FUNCTION Search(VAR cx,cy:integer; S,Ops:string):boolean;
  33. PROCEDURE SearchLast;
  34. PROCEDURE DoSearch;
  35.  
  36. IMPLEMENTATION
  37.  
  38.  
  39. USES Dos;
  40.  
  41. FUNCTION CheckAbort:Boolean;
  42. VAR
  43.   cc:char;
  44. BEGIN
  45.   IF KeyPressed THEN
  46.   BEGIN
  47.     cc:=upcase(ReadKey);
  48.     IF (cc = 'P') OR (cc = ^S) THEN
  49.     BEGIN
  50.       cc  :=  readkey;
  51.       cc  :=  #0;
  52.     END;
  53.     CheckAbort:=(CC=' ');
  54.   END
  55.   ELSE CheckAbort:=FALSE;
  56. END;
  57.  
  58.  
  59.  
  60.  
  61. PROCEDURE input1(VAR s : string; ml : integer; ToUp : boolean);
  62. VAR
  63.   ch : char;
  64.  
  65. BEGIN
  66.   s:='';
  67.   REPEAT
  68.     ch := GetKey;
  69.     IF ToUp THEN
  70.       ch := upcase(ch);
  71.     IF (ch IN [#32..#255]-[#127]) AND (length(s)<=ml) THEN
  72.     BEGIN
  73.       s:=s+ch;
  74.       prompt(ch);
  75.     END
  76.     ELSE
  77.     CASE ch OF
  78.       #8,#127 : IF Length(s)>0 THEN
  79.                 BEGIN
  80.                   prompt(#8#32#8);
  81.                   delete(s,length(s),1);
  82.                 END;
  83.       ^X, ^U  : WHILE s<>'' DO
  84.                 BEGIN
  85.                   prompt(#8#32#8);
  86.                   delete(s,length(s),1);
  87.                 END;
  88.     END;
  89.  UNTIL (ch = #13);
  90.  nl;
  91. END;
  92.  
  93. PROCEDURE input(VAR i : string; maxlength : integer);
  94. BEGIN
  95.   input1(i,maxlength,false);
  96. END;
  97.  
  98.  
  99. PROCEDURE inputup(VAR i : string; maxlength : integer);
  100. BEGIN
  101.   input1(i,maxlength,true);
  102. END;
  103.  
  104.  
  105.  
  106. PROCEDURE SaveInfo;
  107. BEGIN
  108.   reset(InfoFile);
  109.   seek(InfoFile,usernum);
  110.   write(InfoFile,Info);
  111.   close(InfoFile);
  112. END;
  113.  
  114.  
  115.  
  116. PROCEDURE DoJump;
  117. { Prompts for a line to jump to, and then changes cursor position accordingly }
  118. VAR
  119.   s:string;
  120.   line:integer;
  121. BEGIN
  122.   StatusLine3(C2+'Jump to which line? > '+c4+'    '+#8#8#8#8);
  123.   Input(s,4);
  124.   line:=value(s);
  125.   IF (line>0) AND (line<MaxLines) THEN
  126.   BEGIN
  127.     cy:=line;
  128.     cx:=1;
  129.     ViewTop:=cy;
  130.     ViewBottom:=cy+WindowHeight;
  131.     IF ViewBottom>MaxLines THEN BEGIN
  132.       ViewBottom:=MaxLines;
  133.       ViewTop:=ViewBottom-WindowHeight
  134.     END;
  135.   END;
  136.   ansic('0');
  137.   StatusLine3('');
  138. END;
  139.  
  140. FUNCTION Search(VAR cx,cy:integer; S,Ops:string):boolean;
  141. { performs a search from the given coordinates }
  142. VAR
  143.   i:integer;
  144.   found:boolean;
  145.   l:string;
  146. BEGIN
  147.   IF pos('U',ops)>0 THEN S:=TransformString(S);
  148.   Found:=false;
  149.   i:=cy;
  150.   WHILE NOT Found AND (i<MaxLines) Do
  151.   BEGIN
  152.     IF pos('U',ops)>0
  153.       THEN l:=TransformString(Line[i]^.l)
  154.       ELSE l:=Line[i]^.l;
  155.     IF ((cx<pos(s,l)) AND (cy=i)) OR ((pos(s,l)<>0) AND (cy<>i)) THEN
  156.     BEGIN
  157.       cx:=pos(s,l);
  158.       cy:=i;
  159.       Found:=true;
  160.     END
  161.     ELSE inc(i);
  162.   END;
  163.   Search:=Found;
  164. END;
  165.  
  166. PROCEDURE SearchLast;
  167. { Repeats last Search }
  168. BEGIN
  169.   IF NOT Search(cx,cy,SearchString,SearchOps) THEN BEGIN
  170.     StatusLine3('No match found');
  171.     AfterNext:=ClrStatLine3;
  172.   END;
  173. END;
  174.  
  175.  
  176. PROCEDURE DoSearch;
  177. { Prompts for something to search for, and then does the search }
  178. VAR
  179.   x:integer;
  180. BEGIN
  181.   StatusLine3(C2+'Search for > '+C4+dup(' ',60)+ESC+'[60D');
  182.   input(SearchString,60);
  183.   Ansic('0');
  184. {  StatusLine3(C2+'Options > '+C4+'     '+#8#8#8#8#8);
  185.   InputUp(SearchOps,5); }
  186.   SearchOps:='U';
  187.   ansic('0');
  188.   StatusLine3('');
  189.   IF NOT Search(cx,cy,SearchString,SearchOps) THEN BEGIN
  190.     StatusLine3('No match found');
  191.     AfterNext:=ClrStatLine3;
  192.   END;
  193. END;
  194.  
  195.  
  196.  
  197.  
  198.  
  199. END.
  200.  
  201.  
  202.